package com.gitee.hljdrl.lite.task;

import com.gitee.hljdrl.utils.string.StringUtil;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

public class AppTaskFactory implements ThreadFactory {
    private final AtomicInteger threadNumber = new AtomicInteger(1);

    @Override
    public Thread newThread(Runnable r) {
        Thread t = new Thread(r);
        t.setName(StringUtil.string("App-Thread-", String.valueOf(threadNumber.getAndIncrement())));
        t.setPriority(Thread.MIN_PRIORITY);
        return t;
    }
}
